from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import JsonResponse


class LoginRequiredJSONMixin(LoginRequiredMixin):

    def handle_no_permission(self):
        """
        重写方法,修改未登录状态的重定向为返回JSON数据
        :return:
        """
        return JsonResponse({'code': 400, 'errmsg': '用户未登录'})